{% extends "admin/base.html" %}

{% block stylesheets %}
	<link rel="stylesheet" href="{{ request.script_root }}/themes/admin/static/css/challenge-board.css">
{% endblock %}


{% block content %}
	{% include "admin/modals/challenges/challenges.html" %}
	{% include "admin/modals/challenges/challenges-solves.html" %}

	{% include "admin/modals/tags/tags.html" %}
	{% include "admin/modals/files/files.html" %}
	{% include "admin/modals/hints/hints.html" %}
	{% include "admin/modals/keys/keys.html" %}


<input type="hidden" value="{{ nonce }}" id="nonce">

{#	Div used to inject update modal #}
<div id="update-modals-entry-div">
</div>

<div class="jumbotron">
	<div class="container">
		<h1>Challenges
			<a class="no-decoration" href="{{ request.script_root }}/admin/chal/new">
				<span role="button" data-toggle="tooltip" title="Create Challenge">
					<i class="btn-fa fas fa-plus-circle"></i>
				</span>
			</a>
		</h1>
	</div>
</div>
<div class="container">
	<div class="row">
		<div class="col-md-12">
			<div>
				<table id="challenges" class="table table-striped">
					<thead>
					<tr>
						<td><b>ID</b></td>
						<td><b>Name</b></td>
						<td class="d-none d-md-table-cell d-lg-table-cell"><b>Category</b></td>
						<td class="d-none d-md-table-cell d-lg-table-cell"><b>Value</b></td>
						<td class="d-none d-md-table-cell d-lg-table-cell"><b>Type</b></td>
						<td class="d-none d-md-table-cell d-lg-table-cell text-center"><b>Status</b></td>
						<td style="width: 200px;"><b>Settings</b></td>
					</tr>
					</thead>
					<tbody>
					{% for challenge in challenges %}
						<tr>
							<td>{{ challenge.id }}</td>
							<td>{{ challenge.name }}</td>
							<td class="d-none d-md-table-cell d-lg-table-cell">{{ challenge.category }}</td>
							<td class="d-none d-md-table-cell d-lg-table-cell">{{ challenge.value }}</td>
							<td class="d-none d-md-table-cell d-lg-table-cell">{{ challenge.type }}</td>
							<td class="d-none d-md-table-cell d-lg-table-cell text-center">
								{% if challenge.hidden %}
									<span class="badge badge-danger">hidden</span>
								{% else %}
									<span class="badge badge-success">visible</span>
								{% endif %}
							</td>
							<td>
								<span class="edit-challenge" data-toggle="tooltip"
									  data-placement="top" chal-id="{{ challenge.id }}"
									  title="Edit {{ challenge.name }}">
									<i class="btn-fa fas fa-pencil-alt" aria-hidden="true" chal-id="{{ challenge.id }}"></i>
								</span>

								<span class="preview-challenge" data-toggle="tooltip"
									  data-placement="top" chal-id="{{ challenge.id }}"
									  title="Preview {{ challenge.name }}">
									<i class="btn-fa fas fa-file-alt" aria-hidden="true" chal-id="{{ challenge.id }}"></i>
								</span>

								<span class="stats-challenge" data-toggle="tooltip"
									  data-placement="top" chal-id="{{ challenge.id }}"
									  title="{{ challenge.name }} solves">
									<i class="btn-fa fas fa-chart-bar" aria-hidden="true"
									   chal-id="{{ challenge.id }}"></i>
								</span>

								<span>&nbsp; &nbsp;</span>

								<span class="edit-keys" data-toggle="tooltip" data-placement="top"
									  title="Edit {{ challenge.name }} flags" chal-id="{{ challenge.id }}">
									<i class="btn-fa fas fa-flag" aria-hidden="true" chal-id="{{ challenge.id }}"></i>
								</span>
								<span class="edit-files" data-toggle="tooltip"
									  data-placement="top" title="Edit {{ challenge.name }} files"
									  chal-id="{{ challenge.id }}">
									<i class="btn-fa fas fa-download edit-files" aria-hidden="true" chal-id="{{ challenge.id }}"></i>
								</span>
								<span class="edit-tags" data-toggle="tooltip" data-placement="top"
									  title="Edit {{ challenge.name }} tags" chal-id="{{ challenge.id }}">
									<i class="btn-fa fas fa-tags" aria-hidden="true" chal-id="{{ challenge.id }}"></i>
								</span>
								<span class="edit-hints" data-toggle="tooltip"
									  data-placement="top" title="Edit {{ challenge.name }} hints"
									  chal-id="{{ challenge.id }}">
									<i class="btn-fa fas fa-question-circle" aria-hidden="true" chal-id="{{ challenge.id }}"></i>
								</span>

								<span>&nbsp; &nbsp;</span>

								<span class="delete-challenge" data-toggle="tooltip"
									  data-placement="top" title="Delete {{ challenge.name }}"
									  chal-id="{{ challenge.id }}">
								<i class="btn-fa fas fa-times" aria-hidden="true" chal-id="{{ challenge.id }}"></i>
								</span>
							</td>
						</tr>
					{% endfor %}
					</tbody>
				</table>
			</div>
		</div>
	</div>
</div>
{% endblock %}

{% block scripts %}
	<script src="{{ request.script_root }}/themes/admin/static/js/challenges/chalboard.js"></script>
	<script src="{{ request.script_root }}/themes/admin/static/js/files/files-utils.js"></script>
	<script src="{{ request.script_root }}/themes/admin/static/js/hints/hints-utils.js"></script>
	<script src="{{ request.script_root }}/themes/admin/static/js/keys/keys-utils.js"></script>
	<script src="{{ request.script_root }}/themes/admin/static/js/tags/tags-utils.js"></script>
	<script src="{{ request.script_root }}/themes/admin/static/js/multi-modal.js"></script>
{% endblock %}
